#
#
CLEANFILES = *~
DISTCLEANFILES = *~

CONDPP = ../../buildtool/condpp.sh

bin_PROGRAMS = edbtool2

AM_YFLAGS = -d -p et2 -t
AM_LFLAGS = -Pet2 --nounistd

SOURCES_common = edbtool2.c edbtool2_cmd.c edbtool2_print.c edbtool2_help.c \
	et2_edb.c et2_edb.h readline.c edbtool2.h \
	edbtool2_cheat_edb.c ../edbd/extcall_dummy.c

if ECM_PARSER

BUILT_SOURCES = toolparser_dbg.y toolparser_nodbg.y \
	toolscan_dbg.l toolscan_nodbg.l \
	toolparser_dbg.c toolparser_nodbg.c \
	toolscan_dbg.c toolscan_nodbg.c

toolparser_dbg.y: toolparser.y
	$(CONDPP) -d $< > $@

toolparser_nodbg.y: toolparser.y
	$(CONDPP) $< > $@

toolscan_dbg.l: toolscan.l
	$(CONDPP) -d $< > $@

toolscan_nodbg.l: toolscan.l
	$(CONDPP) $< > $@

toolscan_dbg.c: toolscan_dbg.l
	flex $(AM_LFLAGS) -d -o$@ $<

toolscan_nodbg.c: toolscan_nodbg.l
	flex $(AM_LFLAGS) -o$@ $<

if ECM_DEBUG

PARSER_SOURCES = toolparser_dbg.y

else

PARSER_SOURCES = toolparser_nodbg.y

endif

else

if ECM_DEBUG

PARSER_SOURCES = toolparser_dbg.c

else

PARSER_SOURCES = toolparser_nodbg.c

endif

endif

if ECM_DEBUG

BFD_LIBRARY = -lbfd @BFD_DEP_LIBS@
SCANNER_SOURCES = toolscan_dbg.c

else

SCANNER_SOURCES = toolscan_nodbg.c

endif

edbtool2_SOURCES = $(SOURCES_common) $(PARSER_SOURCES) $(SCANNER_SOURCES)

INCLUDES = -I../../lib/libbase -I../../lib/libsr -I../../lib/libebc -I../../lib/libedb -I../../lib/libeds

edbtool2_LDFLAGS = -dlopen self

edbtool2_LDADD = ../../lib/libeds/libeds.la \
		../../lib/libedb/libedb.la \
		../../lib/libebc/libebc.la \
		../../lib/libsr/libsr.la \
		../../lib/libbase/libbase.la \
		-lreadline -lhistory -lcurses -lm @LINK_DL@ $(BFD_LIBRARY) -lpthread

EXTRA_DIST = toolscan_dbg.c toolscan_nodbg.c toolscan.l

